﻿<Window x:Class="WpfVisualState.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button Content="Button" Height="44" HorizontalAlignment="Left" Margin="100,54,0,0" Name="button1" VerticalAlignment="Top"   >
            <Button.Style>
                <Style TargetType="Button">
                    <Setter Property="Background" Value="Red" />
                    <Setter Property="MinWidth" Value="150" />
                    <Setter Property="Cursor" Value="Hand" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="Button">
                                <Border x:Name="border"  BorderBrush="LightBlue" BorderThickness="2" CornerRadius="3" Background="LightSteelBlue" Padding="3">
                                    <Border.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <TranslateTransform x:Name="tts"  X="0" Y="0"/>
                                        </TransformGroup>
                                    </Border.RenderTransform>
                                    <ContentPresenter  Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualStateGroup.Transitions>
                                                <VisualTransition  From="Normal" To="MouseOver" GeneratedDuration="0">
                                                    <Storyboard>
                                                        <ColorAnimation Storyboard.TargetName="border"  FillBehavior="HoldEnd" Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)"
                                                                From="LightSteelBlue"     To="LightSkyBlue" />
                                                    </Storyboard>
                                                </VisualTransition>
                                            </VisualStateGroup.Transitions>
                                            <VisualState x:Name="Normal" >

                                            </VisualState>
                                            <VisualState x:Name="MouseOver" >

                                            </VisualState>
                                            <VisualState x:Name="Pressed" >
                                                <Storyboard>
                                                    <!--<DoubleAnimation   Storyboard.TargetProperty="Width" Storyboard.TargetName="border"  From="150" To="180"/>-->
                                                    <DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.X)"
                                                                     From="0" To="5" Duration="0:0:0.1" />
                                                    <DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)" 
                                                                     From="0" To="5"  Duration="0:0:0.1"/>
                                                    <!--<DoubleAnimation Storyboard.TargetName="tts" Storyboard.TargetProperty="X" From="0" To="5" Duration="0:0:0.01" />
                                                    <DoubleAnimation Storyboard.TargetName="tts" Storyboard.TargetProperty="Y" From="0" To="5"  Duration="0:0:0.01"/>-->
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Button.Style>

        </Button>
    </Grid>
</Window>
